#include "vlog/vlog.h"
#include <iostream>
#include <unordered_set>

auto g_vlog = VLOG_GET_ROOT();

auto g_fileLog = VLOG_GET_LOG("file");

class TestTime
{
public:
    TestTime()
    {
        m_tm = std::chrono::system_clock::now();
    }

    ~TestTime()
    {
        auto now = std::chrono::system_clock::now();
        std::cout << "time: " << std::chrono::duration_cast<std::chrono::milliseconds>(now - m_tm).count()
              << " milliseconds\n";
    }

private:

    std::chrono::system_clock::time_point m_tm;

};

int conut = 0;

void Run(void)
{
    for (long long i = 5900000; i >= 0; --i)
    {
        VLOG_INFO(g_fileLog) << "test " << conut++;
    }
}

int main(int argc, char* argv[])
{

    vlog::LogAppender::ptr filelog(new vlog::FileLogAppender("test.log"));

    g_fileLog->AddLogAppender(filelog);
    //auto time = std::chrono::system_clock::now();
    TestTime tm;
    VLOG_INFO(g_fileLog) << "test " << conut++;
    std::thread t1(Run);
    // std::thread t2(Run);
    //  while(conut < 100000000 - 1)
    //  {
    //      VLOG_INFO(g_fileLog) << std::to_string(conut);
    //      std::this_thread::sleep_for(std::chrono::seconds(2));
    //  }

    t1.join();
    // t2.join();
    

    return 0;
}
